<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="author" content="苏">
    
    
    
    
    
    
    <title>search | 苏大人~</title>
    <link href="https://suqaq.github.io" rel="prefetch" />
	
		<link rel="shortcut icon" href="/imgs/favicon.ico">
	

    
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/aos.css">
<link rel="stylesheet" href="/css/style.css">

    
<script src="/js/jquery.min.js"></script>

    
<script src="/js/bootstrap.min.js"></script>

    
<script src="/js/aos.js"></script>

    
<script src="/js/highslide/highslide-full.min.js"></script>

    
<link rel="stylesheet" href="/js/highslide/highslide.css">

    <style type="text/css">
        @media (max-width: 768px) {
            body {
                background-color: #f0f0f0;
                background: url('/imgs/xsbg.gif');
                background-attachment: fixed;
            }
        }
    </style>
    
    <!--<script type="text/javascript">
      if (document.images) {
        var avatar = new Image();
        avatar.src = '/imgs/avatar.jpg'
        var previews = 'preview1.jpg,preview2.jpg,preview3.jpg,preview4.jpg'.split(',')
        var previewsPreLoad = []
        for(var i = 0; i < length; i++) {
          previewsPreLoad.push(new Image())
          previewsPreLoad[previewsPreLoad.length - 1].src = '/imgs/preview' + previews[i]
        }
      }
    </script>-->
<meta name="generator" content="Hexo 5.4.0"></head>
<body>
    <!-- 背景轮播图功能 -->
    <section class="hidden-xs">
    <ul class="cb-slideshow">
        <li><span>天若</span></li>
        <li><span>有情</span></li>
        <li><span>天亦老</span></li>
        <li><span>我为</span></li>
        <li><span>长者</span></li>
        <li><span>续一秒</span></li>
    </ul>
</section>
    <!-- 欧尼酱功能, 谁用谁知道 -->
    
    <header class="navbar navbar-inverse" id="gal-header">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed"
                    data-toggle="collapse" data-target=".bs-navbar-collapse"
                    aria-expanded="false">
                <span class="fa fa-lg fa-reorder"></span>
            </button>
            <a href="https://suqaq.github.io">
                
                <style>
                    #gal-header .navbar-brand {
                        height: 54px;
                        line-height: 24px;
                        font-size: 28px;
                        opacity: 1;
                        background-color: rgba(0,0,0,0);
                        text-shadow: 0 0 5px #fff,0 0 10px #fff,0 0 15px #fff,0 0 20px #228DFF,0 0 35px #228DFF,0 0 40px #228DFF,0 0 50px #228DFF,0 0 75px #228DFF;
                    }
                </style>
                <!-- 这里使用文字(navbar_text or config.title) -->
                <div class="navbar-brand">sama</div>
                
            </a>
        </div>
        <div class="collapse navbar-collapse bs-navbar-collapse">
            <ul class="nav navbar-nav" id="menu-gal">
                
                
                <li class="">
                    <a href="/">
                        <i class="fa fa-home"></i>首页
                    </a>
                </li>
                
                
                
                <li class="">
                    <a href="/archives">
                        <i class="fa fa-archive"></i>归档
                    </a>
                </li>
                
                
                
                
                <li class="">
                    <a href="/categories">
                        <i class="fa fa-list"></i>分类
                    </a>
                </li>
                
                
                
                
                
                <li class="">
                    <a href="/tags">
                        <i class="fa fa-tags"></i>标签
                    </a>
                </li>
                
                
                
                
                <li class="">
                    <a href="/about">
                        <i class="fa fa-user"></i>关于我
                    </a>
                </li>
                
                
            </ul>
        </div>
    </div>
</header>
    <div id="gal-body">
        <div class="container">
            <div class="row">
                <div class="col-md-8 gal-right" id="mainstay">
                    <!-- 搜索页面(尽可能接近ZanBlog搜索功能) -->

<!-- search自定义页面 -->
<script type="text/javascript">

	var htmlEntityMap = {
		'&': '&amp;',
		'<': '&lt;',
		'>': '&gt;',
		'"': '&quot;',
		'\'': '&#39;',
		'/': '&#x2F;'
	};

	// 参照hexo过滤html的方法(事实上感觉静态也没什么可以过滤的)
	function escapeKey(str) {
		if (typeof str !== 'string') throw new TypeError('str must be a string!');

		// http://stackoverflow.com/a/12034334
		return str.replace(/[&<>"'\/]/g, function(a) {
			return htmlEntityMap[a];
		});
	}

	var query = decodeURIComponent(window.location.search).substring(1).split('&')
    // 获取搜索关键词
    var s = escapeKey(query[0].split('=')[1])
    // 获取当前页数
    var p = query.length > 1 ? query[1].split('=')[1] : 1
    // 获取每页的页码数
    var pageSize = '10'
    var useLeancloud = ''
    var useComment = ('false' === 'true')
    $.getJSON('/content.json', function (json) {
      $('#search-breadcrumb').append(`搜索'${s}'的结果`)
      var result = getArticles(s, 'posts', json).concat(getArticles(s, 'pages', json))
      if (result.length === 0 || result.length <= (p - 1) * pageSize) {
      	// TODO 显示404页面
      } else {
        displaySearchResult(result.slice((p - 1) * pageSize, p * pageSize))
        displayPagination(result)
      }
    })

    function getArticles(val, type, json) {
      return json[type].filter((e) => {
        return e.title.indexOf(val) !== -1 || e.text.indexOf(val) !== -1
      })
    }

    function displaySearchResult(result) {
      var resultList = $('#article-list')
      result.forEach(function (article) {
      	var [month, day] = article.date.split('-')
        ''
        ''
        var defaultPreview = '/imgs/preview/preview3.jpg'
        var preview = article.preview ? article.preview : defaultPreview
        var path = '/' + article.path
        resultList.append(`<div class="article well clearfix article-body article-excerpt" data-aos="flip-up">
                                <div class="data-article hidden-xs">
                                    <span class="month">${month}月</span>
                                    <span class="day">${day}</span>
                                </div>
                                <section class="hidden-xs">
                                    <div class="title-article">
                                        <h1>
                                            <a href="${path}">
                                                <span>${article.title}</span>
                                            </a>
                                        </h1>
                                    </div>
                                    <div class="tag-article">
                                    ${ article.tags.length > 0 ? `<span class="label label-gal"><i class="fa fa-tags"></i>${
                                    	article.tags.map(function (tag) {
						                 return `<a href=${ tag.permalink }>${ tag.name }</a>`
                                    	}).join(', ') }</span>` : '' }
                                    ${ useLeancloud ? '<span class="label label-gal"><i class="fa fa-eye"></i></span>' : ''}
                                    </div>
                                    <div class="alert alert-gal article-body content-article">
                                         <div class="item">
                                            <a href="${path}">
                                                <div class="img">
                                                    <img src="${preview}" alt="${article.title}">
                                                </div>
                                                <div class="info">
                                                    <p>${article.excerpt}</p>
                                                </div>
                                            </a>
                                         </div>
					                </div>
					            </section>
                           </div>`)
      })
      if (useLeancloud) {
        var Counter = AV.Object.extend('Counter')
        showPostsTime(Counter)
      }
      if (useComment) {
      	showCommentCount()
      }
    }

    function displayPagination(result) {
      var pgContainer = $('#gal-pagination')
      var pg = $(pgContainer.find('.pagination-gal')[0])
      if(result.length > 0) {
        pgContainer.css('display', 'block')
      }
      var num = Math.ceil(result.length / pageSize)
      var root = '/search'
      var link = root + `/index.html?s=${s}`
      if(p > 1) {
      	pg.append(`<li class="prev"><a href="${link}&page=${p-1}">«</a></li>`)
      }
      if(p > 7) {
      	pg.append(`<li><a href="${link}">1</a></li>
                   <li><span>...</span></li>`)
        for(var i = p - 3; i < p; i++) {
          pg.append(`<li><a href="${link}&page=${i}">${i}</a></li>`)
        }
      } else {
      	for(var j = 1; j < p; j++) {
          pg.append(`<li><a href="${link}${j === 1 ? '' : `&page=${j}`}">${j}</a></li>`)
        }
      }
      pg.append(`<li class="current"><span>${p}</span></li>`)
      if(p + 7 < num) {
      	for(var i = p + 1; i <= p + 3; i++) {
          pg.append(`<li><a href="${link}&page=${i}">${i}</a></li>`)
        }
        pg.append(`<li><span>...</span></li>`)
      } else {
      	for(var j = p + 1; j <= num; j++) {
          pg.append(`<li><a href="${link}&page=${j}">${j}</a></li>`)
        }
      }
      if(p < num) {
      	pg.append(`<li class="next"><a href="${link}&page=${p+1}">»</a></li>`)
      }
    }

    function showPostsTime(Counter) {
      var entries = []
      var excerpts = $('.article-excerpt')
      excerpts.each(function () {
        entries.push($(this).find('.title-article').first().find('a').attr('href').trim())
      })
      var query = new AV.Query(Counter)
      query.containedIn('url', entries)
      query.find().then(function (result) {
        excerpts.each(function () {
          var href = $(this).find('.title-article').first().find('a').attr('href').trim()
          var r = result.filter(function (e) {
            return e.get('url') === href
          })
          if(r.length > 0) {
            $(this).find('i.fa-eye').each(function () {
              $(this).after(' ' + r[0].get('time') + ' ℃')
            })
          } else {
            $(this).find('i.fa-eye').each(function () {
              $(this).after(' 0 ℃')
            })
          }
        })
      }).then(function (error) {
        console.log('Error:' + error.code + ' ' + error.message)
      })
    }

    function showCommentCount() {
      const excerpts = $('.article-excerpt')
      const owner = window.commentConfig.owner
      const repo = window.commentConfig.repo
      $.ajax({
        url: "https://api.github.com/repos/" + owner + '/' + repo + '/issues',
        data: {
          creator: owner
        }
      }).done(function(issues) {
        excerpts.each(function () {
          const that = $(this)
          that.find('h1 > a > span').each(function () {
            const title = $(this).text()
            const tags = that.find('div.tag-article')
            const issue = issues.filter(function (issue) {
              return issue.title === title
            })
            const comments = issue.length > 0 ? issue[0].comments : 0
            tags.each(function () {
              $(this).append('<span class="label label-gal"><i class="fa fa-comments"></i><a> ' + comments + '</a></span>')
            })
          })
        })
      }).fail(function (error) {
        console.log(error)
      });
    }

</script>
<div class="breadcrumb breadcrumb-gal" id="search-breadcrumb">
    <i class="fa fa-home"></i>
</div>
<div id="article-list"></div>
<div id="gal-pagination" class="clearfix" style="display: none;">
    <ul class="pagination pagination-gal pull-right"></ul>
</div>
<!-- 404页面 -->

                </div>
                <aside class="col-md-4 gal-left" id="sidebar">
    <!-- 此为sidebar的搜索框, 非搜索结果页面 -->
<aside id="sidebar-search">
    <div class="search hidden-xs" data-aos="fade-up" data-aos-duration="2000">
        <form class="form-inline clearfix" id="search-form" method="get"
              action="/search/index.html">
            <input type="text" name="s" class="form-control" id="searchInput" placeholder="搜索文章~" autocomplete="off">
            <button class="btn btn-danger btn-gal" type="submit">
                <i class="fa fa-search"></i>
            </button>
        </form>
    </div>
</aside>
    <aside id="sidebar-author">
    <div class="panel panel-gal" data-aos="flip-right" data-aos-duration="3000">
        <div class="panel-heading" style="text-align: center">
            <i class="fa fa-quote-left"></i>
            苏
            <i class="fa fa-quote-right"></i>
        </div>
        <div class="author-panel text-center">
            <img src="/imgs/avatar.jpg" width="140" height="140"
                 alt="个人头像" class="author-image">
            <p class="author-description"></p>
        </div>
    </div>
</aside>
    
    <aside id="sidebar-recent_comments">
    <div class="panel panel-gal recent hidden-xs" data-aos="fade-up" data-aos-duration="2000">
        <div class="panel-heading">
            <i class="fa fa-comments"></i>
            最新评论
            <i class="fa fa-times-circle panel-remove"></i>
            <i class="fa fa-chevron-circle-up panel-toggle"></i>
        </div>
        <ul class="list-group list-group-flush"></ul>
    </div>
</aside>
    
    <!-- 要配置好leancloud才能开启此小工具 -->
    
    
    <aside id="sidebar-recent_posts">
    <div class="panel panel-gal recent hidden-xs" data-aos="fade-up" data-aos-duration="2000">
        <div class="panel-heading">
            <i class="fa fa-refresh"></i>
            近期文章
            <i class="fa fa-times-circle panel-remove"></i>
            <i class="fa fa-chevron-circle-up panel-toggle"></i>
        </div>
        <ul class="list-group list-group-flush">
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2021/06/27/hello-world/">Hello World</a>
                </span>
            </li>
            
        </ul>
    </div>
</aside>
    
    
    <aside id="sidebar-rand_posts">
    <div class="panel panel-gal recent hidden-xs" data-aos="fade-up" data-aos-duration="2000">
        <div class="panel-heading">
            <i class="fa fa-refresh"></i>
            随机文章
            <i class="fa fa-times-circle panel-remove"></i>
            <i class="fa fa-chevron-circle-up panel-toggle"></i>
        </div>
        <ul class="list-group list-group-flush">
            
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2021/06/27/hello-world/">Hello World</a>
                </span>
            </li>
            
        </ul>
    </div>
</aside>
    
    
    <aside id="gal-sets">
        <div class="panel panel-gal hidden-xs" data-aos="fade-up" data-aos-duration="2000">
            <ul class="nav nav-pills pills-gal">

                
                <li>
                    <a href="/search/index.html#sidebar-tags" data-toggle="tab" id="tags-tab">热门标签</a>
                </li>
                
                
                <li>
                    <a href="/search/index.html#sidebar-friend-links" data-toggle="tab" id="friend-links-tab">友情链接</a>
                </li>
                
                
                <li>
                    <a href="/search/index.html#sidebar-links" data-toggle="tab" id="links-tab">个人链接</a>
                </li>
                
            </ul>
            <div class="tab-content">
                
                <div class="cloud-tags tab-pane nav bs-sidenav fade" id="sidebar-tags">
    
</div>
                
                
                <div class="friend-links tab-pane nav bs-sidenav fade" id="sidebar-friend-links">
    
    <li>
        <a href="http://kdays.net/days/" target="_blank">KDays Forum</a>
    </li>
    
    <li>
        <a href="http://www.gal123.com/" target="_blank">绅士导航♂</a>
    </li>
    
    <li>
        <a href="http://www.moe123.com/" target="_blank">萌导航</a>
    </li>
    
</div>
                
                
                <div class="links tab-pane nav bs-sidenav fade" id="sidebar-links">
    
    <li>
        <a href="https://github.com/ZEROKISEKI/" target="_blank">Github</a>
    </li>
    
    <li>
        <a href="https://coding.net/u/SORA1" target="_blank">Coding</a>
    </li>
    
    <li>
        <a href="https://www.zhihu.com/people/aonosora/activities" target="_blank">知乎</a>
    </li>
    
</div>
                
            </div>
        </div>
    </aside>
    
</aside>
            </div>
        </div>
    </div>
    <footer id="gal-footer">
    <div class="container">
        Copyright © 2021 苏 Powered by <a href="https://hexo.io/" target="_blank">Hexo</a>.&nbsp;Theme by <a href="https://github.com/ZEROKISEKI" target="_blank">AONOSORA</a>
    </div>
</footer>

<!-- 回到顶端 -->
<div id="gal-gotop">
    <i class="fa fa-angle-up"></i>
</div>
<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"jsonPath":"/live2dw/assets/z16.model.json"},"display":{"position":"left","width":145,"height":315,"vOffset":-35},"mobile":{"show":true,"scale":0.5},"react":{"opacityDefault":0.7,"opacityOnHover":0.8},"log":false});</script></body>

<script src="/js/activate-power-mode.js"></script>

<script>

    // 配置highslide
	hs.graphicsDir = '/js/highslide/graphics/'
    hs.outlineType = "rounded-white";
    hs.dimmingOpacity = 0.8;
    hs.outlineWhileAnimating = true;
    hs.showCredits = false;
    hs.captionEval = "this.thumb.alt";
    hs.numberPosition = "caption";
    hs.align = "center";
    hs.transitions = ["expand", "crossfade"];
    hs.lang.number = '共%2张图, 当前是第%1张';
    hs.addSlideshow({
      interval: 5000,
      repeat: true,
      useControls: true,
      fixedControls: "fit",
      overlayOptions: {
        opacity: 0.75,
        position: "bottom center",
        hideOnMouseOut: true
      }
    })

    // 初始化aos
    AOS.init({
      duration: 1000,
      delay: 0,
      easing: 'ease-out-back'
    });

</script>
<script>
	POWERMODE.colorful = 'true';    // make power mode colorful
	POWERMODE.shake = 'true';       // turn off shake
	// TODO 这里根据具体情况修改
	document.body.addEventListener('input', POWERMODE);
</script>
<script>
    window.slideConfig = {
      prefix: '/imgs/slide/background',
      ext: 'jpg',
      maxCount: '6'
    }
</script>

<script src="/js/hs.js"></script>
<script src="/js/blog.js"></script>




</html>